import type { TrialVO, TrialForm, TrialQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询临床试验信息列表
 * @param params
 * @returns 临床试验信息列表
 */
export function trialList(params?: TrialQuery) {
  return requestClient.get<PageResult<TrialVO>>('/business/trial/list', {
    params,
  });
}

/**
 * 查询临床试验信息列表
 * @param params
 * @returns 临床试验信息列表
 */
export function trialListByProject(projectId: string | number) {
  return requestClient.get<TrialVO[]>(
    `/business/trial/listByProject/${projectId}`,
  );
}
/**
 * 导出临床试验信息列表
 * @param params
 * @returns 临床试验信息列表
 */
export function trialExport(params?: TrialQuery) {
  return commonExport('/business/trial/export', params ?? {});
}

/**
 * 查询临床试验信息详情
 * @param id id
 * @returns 临床试验信息详情
 */
export function trialInfo(id: ID) {
  return requestClient.get<TrialVO>(`/business/trial/${id}`);
}

/**
 * 新增临床试验信息
 * @param data
 * @returns void
 */
export function trialAdd(data: TrialForm) {
  return requestClient.postWithMsg<void>('/business/trial', data);
}

/**
 * 更新临床试验信息
 * @param data
 * @returns void
 */
export function trialUpdate(data: TrialForm) {
  return requestClient.putWithMsg<void>('/business/trial', data);
}

/**
 * 删除临床试验信息
 * @param id id
 * @returns void
 */
export function trialRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/business/trial/${id}`);
}
